const util = require('../../../utils/util.js');
const api = require('../../../config/api.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    id: 0,
    card: {}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    if (options.id) {
      this.setData({
        id: options.id
      });
    }
    this.getCard();
  },

  getCard: function() {
    let that = this;
    util.request(api.GetCardUrl, {
      id: that.data.id
    }).then(function(res) {
      if (res.success) {
        that.setData({
          card: res.data
        });
      }
    });
  },
  goActivate: function() {
    let that = this;
    if (that.data.card.notNum < 1) {
      util.showErrorToast('没有可激活的卡');
      return false;
    }
    wx.navigateTo({
      url: '/pages/card/activation/activation?id=' + that.data.card.id + '&notNum=' + that.data.card.notNum
    })
  },
  geShare: function() {
    let that = this;

  },
  goCustom: function() {
    let that = this;
    if (that.data.card.activeNum < 1) {
      util.showErrorToast('没有可使用的卡');
      return false;
    }
    wx.navigateTo({
      url: '/pages/card/send/send'
    })
  }
})